﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DingHeng.TransportationManagement.DataAccess;
using DingHeng.TransportationManagement.Entity;

namespace DingHeng.TransportationManagement.Business
{
    public class TransportationFormBiz
    {
        public TransportationForm LoadById(Guid id)
        {
            using (TransportationFormDataAccess vdfa = new TransportationFormDataAccess())
            {
                return vdfa.LoadByCondition(v => v.ID == id).FirstOrDefault();
            }
        }
        public int Save(TransportationForm entity)
        {
            using (TransportationFormDataAccess tfd = new TransportationFormDataAccess())
            {
                return tfd.Save(entity);
            }
        }

        public bool Verify(TransportationForm entity)
        {
            //TODO:根据业务逻辑编写校验规则
            return true;
        }


        public List<TransportationForm> GetList(TransportationFormCriteria criteria, Pager<TransportationForm> pager)
        {
            using (TransportationFormDataAccess access = new TransportationFormDataAccess())
            {
                IQueryable<TransportationForm> query = access.LoadByCondition(v => v.IsActive == true);

                access.GetPagerList(query, pager);
            }
            return pager.CurrentPageList;
        }
    }
}
